(self.AMP=self.AMP||[]).push({m:0,v:"2110011758000",n:"amp-iframe",ev:"0.1",l:true,f:function(AMP,_){"use strict";var m;function aa(a){var b=0;return function(){return b=c&&(b[k]=Math.random() src. Must start with https://. Found %s",a);var h=f.parse(d);F(!/\sallow-same-origin\s/i.test(" "+e+" ")||l!=h.origin&&"data:"!=g,"Origin of must not be equal to container %s if allow-same-origin is set. See https://github.com/ampproject/amphtml/blob/main/docs/spec/amp-iframe-origin-policy.md for details.",a);F(!(ja(k,"."+Da.thirdPartyFrameHost)||ja(k,".ampproject.org")),"amp-iframe does not allow embedding of frames from ampproject.*: %s",b);return b}function kb(a){var b=a.element.getLayoutBox(),c=Math.min(600,.75*a.getViewport().getSize().height);F(b.top>=c," elements must be positioned outside the first 75% of the viewport or 600px from the top (whichever is smaller): %s Current position %s. Min: %sPositioning rules don't apply for iframes that use `placeholder`.See https://github.com/ampproject/amphtml/blob/main/extensions/amp-iframe/amp-iframe.md#iframe-with-placeholder for details.",a.element,b.top,c)}function lb(a,b){if(b){a=S(a.element,"url").parse(b);var c=a.hash;"data:"==a.protocol||c&&"#"!=c||(a=b.indexOf("#"),b=(-1==a?b:b.substring(0,a))+"#amp=1");return b}}m.preconnectCallback=function(a){this.iframeSrc&&Q(this.win,"preconnect").url(this.getAmpDoc(),this.iframeSrc,a)};m.buildCallback=function(){this.o=this.element.getAttribute("sandbox");var a;if(!(a=lb(this,this.element.getAttribute("src"))))if(a=this.element.getAttribute("srcdoc")){F(!(" "+this.o+" ").match(/\s+allow-same-origin\s+/i),"allow-same-origin is not allowed with the srcdoc attribute %s.",this.element);if("undefined"!==typeof TextEncoder)var b=new TextEncoder("utf-8").encode(a);else{a=unescape(encodeURIComponent(a));b=new Uint8Array(a.length);for(var c=0;cc||e>b)&&20>=c-f&&20>=b-e){c=!0;break a}}c=!1}this.R=c;c=this.element;b=c.getLayoutSize();d=b.height;this.B=10=d)}this.W=c};m.layoutCallback=function(){var a=this;F(!this.W,"amp-iframe is not used for displaying fixed ad. Please use amp-sticky-ad and amp-ad instead.");this.F||kb(this);this.I&&F(this.getOverflowElement(),"Overflow element must be defined for resizable frames: %s",this.element);if(!this.iframeSrc)return ea();if(this.B&&!this.getAmpDoc().registerSingleton(1))return console.error("Only 1 analytics/tracking iframe allowed per page. Please use amp-analytics instead or file a GitHub issue for your use case: https://github.com/ampproject/amphtml/issues/new/choose"),ea();var b=this.element.ownerDocument.createElement("iframe");this.h=b;b.classList.add("i-amphtml-fill-content");b.name="amp_iframe"+hb++;this.F&&pa(b,-1);fb(gb,this.element,b);var c=b.getAttribute("allow")||"";c=c.replace("autoplay","autoplay-disabled");b.setAttribute("allow",c);b.setAttribute("sandbox",this.o||"");b.src=this.iframeSrc;this.B||(this.G=new Oa(this,b));b.onload=function(){b.readyState="complete";a.U();a.B&&(a.iframeSrc=null,R(a.win,"timer").promise(5e3).then((function(){ya(b);a.element.setAttribute("amp-removed","");a.h=null})))};I(b,"embed-size",(function(d){Z(a,d.height,d.width)}),void 0,void 0,!0);this.L=Ea(this.win,(function(d){if(a.h&&d.source===a.h.contentWindow&&(d=d.data,"string"===typeof d&&d.startsWith("pym"))){var e=d.split(/xPYMx/);"height"===e[2]?Z(a,parseInt(e[3],10),void 0):"width"===e[2]?Z(a,void 0,parseInt(e[3],10)):E().warn("amp-iframe","Unsupported Pym.js message: "+d)}}));this.F&&I(b,"embed-ready",this.U.bind(this));I(b,"send-consent-data",(function(d,e,f){nb(a,e,f)}));this.D.appendChild(b);return this.loadPromise(b).then((function(){a.D!=a.element&&R(a.win,"timer").delay((function(){a.mutateElement((function(){a.D.classList.add("amp-active")}))}),1e3);a.Y.updatePlaying(!0)}))};function nb(a,b,c){cb(a.element,a.getConsentPolicy()).then((function(d){var e=Object.assign(y({sentinel:"amp",type:"consent-data"}),d);b.postMessage(e,c)}))}m.unlayoutCallback=function(){this.L&&(this.L(),this.L=null);this.h&&(ya(this.h),this.K&&this.togglePlaceholder(!0),this.h=null,this.G&&(this.G.destroy(),this.G=null));this.Y.updatePlaying(!1);return!0};m.getLayoutPriority=function(){return this.R?2:this.B?1:AMP.BaseElement.prototype.getLayoutPriority.call(this)};m.mutatedAttributesCallback=function(a){var b=a.src;void 0!==b&&(this.iframeSrc=lb(this,b),this.h&&(this.h.src=jb(this,this.iframeSrc,this.o)));this.h&&a.title&&fb(["title"],this.element,this.h)};m.unlayoutOnPause=function(){return!0};m.U=function(){var a=this;this.K&&this.getVsync().mutate((function(){a.h&&(pa(a.h,0),a.togglePlaceholder(!1))}))};m.firstLayoutCompleted=function(){};m.throwIfCannotNavigate=function(){if(!/\sallow-top-navigation\s/i.test(" "+this.o+" "))throw E().createError('"AMP.navigateTo" is only allowed on when its "sandbox" attribute contains "allow-top-navigation".')};function Z(a,b,c){if(a.I)if(100>b)a.user().error("amp-iframe","Ignoring embed-size request because the resize height is less than 100px. If you are using amp-iframe to display ads, consider using amp-ad instead.",a.element);else{var d,e;b=parseInt(b,10);isNaN(b)||(d=Math.max(b+(a.element.offsetHeight-a.h.offsetHeight),b));c=parseInt(c,10);isNaN(c)||(e=Math.max(c+(a.element.offsetWidth-a.h.offsetWidth),c));void 0!==d||void 0!==e?a.attemptChangeSize(d,e).then((function(){void 0!==d&&a.element.setAttribute("height",d);void 0!==e&&a.element.setAttribute("width",e);a.element.overflowCallback(!1,d,e)}),(function(){})):a.user().error("amp-iframe","Ignoring embed-size request because no width or height value is provided",a.element)}else a.V||(a.user().error("amp-iframe","Ignoring embed-size request because this iframe is not resizable",a.element),a.V=!0)}function mb(a){if(eb(a.win)){var b=a.element,c=b.getAttribute("src");c&&(a.j=S(b,"url").parse(c).origin);a.registerAction("postMessage",(function(f){a.j?a.h.contentWindow.postMessage(f.args,a.j):E().error("amp-iframe",'"postMessage" action is only allowed with "src"attribute with an origin.')}));if(a.j){var d=0,e=function(f){if(f.source===a.h.contentWindow)if(f.origin!==a.j)E().error("amp-iframe",'"message" received from unexpected origin: '+f.origin+". Only allowed from: "+a.j);else{if(a.getAmpDoc().getRootNode().activeElement!==a.h)var g=!1;else g=a.win.document.createElement("audio"),qa(g),g=g.paused?!1:!0;if(g){var k=f.data;try{var l=JSON.parse(JSON.stringify(k))}catch(v){E().error("amp-iframe",'Data from "message" event must be JSON.');return}var h=a.win;f=y({data:l});g={detail:f};Object.assign(g,void 0);"function"==typeof h.CustomEvent?f=new h.CustomEvent("amp-iframe:message",g):(h=h.document.createEvent("CustomEvent"),h.initCustomEvent("amp-iframe:message",!!g.bubbles,!!g.cancelable,f),f=h);S(a.element,"action").trigger(a.element,"message",f,3)}else d++,E().error("amp-iframe",'"message" event may only be triggered from a user gesture.'),10<=d&&(E().error("amp-iframe",'Too many non-gesture-triggered "message" events; detaching event listener.'),a.win.removeEventListener("message",e))}};a.win.addEventListener("message",e)}}}m.ba=function(a){this.j=a};AMP.registerElement("amp-iframe",W)}});//# sourceMappingURL=amp-iframe-0.1.js.map